<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <script>
            /*
                array.reduceRight(callback[, initialValue])
                实现上差异在于reduceRight是从数组的末尾开始实现
            */ 
            var data = [1, 2, 3, 4];
            var specialDiff = data.reduceRight(function (previous, current, index) {
                console.log("previous:"+previous);
                console.log("current:"+current);
                console.log("index:"+index);
                console.log('--------')
                if (index == 0) {
                    return previous + current;
                }
                return previous - current;
            });
            console.log(specialDiff); // 0
        </script>   
    </body>
</html>